Import Libraries


In [1]:
import cv2

In [2]:
import matplotlib.pyplot as plt

Read image


In [3]:
img = cv2.imread('rgbimage.png')

In [4]:
img_RGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

In [5]:
plt.imshow(img_RGB)


Out[5]:
<matplotlib.image.AxesImage at 0x7ffb21f80f98>

In [6]:
plt.show()



In [7]:
print('Image shape:', img_RGB.shape)


Image shape: (225, 225, 3)

Image has 3 planes RGB, now extracting each one of them seperately


In [8]:
plt.figure(figsize=(10,6))


Out[8]:
<matplotlib.figure.Figure at 0x7ffb21f3a1d0>

In [9]:
plt.subplot(1,3,1)


Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ffb21f3a978>

In [10]:
plt.title('Red Plane')


Out[10]:
<matplotlib.text.Text at 0x7ffb21ecbb00>

In [11]:
plt.imshow(img_RGB[:,:,0])


Out[11]:
<matplotlib.image.AxesImage at 0x7ffb21e7d588>

In [12]:
plt.subplot(1,3,2)


Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ffb21e7d668>

In [13]:
plt.title('Green Plane')


Out[13]:
<matplotlib.text.Text at 0x7ffb21e473c8>

In [14]:
plt.imshow(img_RGB[:,:,1])


Out[14]:
<matplotlib.image.AxesImage at 0x7ffb21faba90>

In [15]:
plt.subplot(1,3,3)


Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ffb21fab2e8>

In [16]:
plt.title('Blue Plane')


Out[16]:
<matplotlib.text.Text at 0x7ffb21e19cc0>

In [17]:
plt.imshow(img_RGB[:,:,2])


Out[17]:
<matplotlib.image.AxesImage at 0x7ffb21dc6cc0>

In [18]:
plt.show()